import { request } from './request';

// detail组件的相关网络请求封装

// 详情页商品数据
export function getGoodsDetail(iid) {
    return request({
        url: '/detail',
        params: {
            iid:iid
        }
    })
}



// 商品详情页里面涉及到的数据在接口的位置比较杂乱，先做个封装整理
// , 再去调用对象里的数据
export class Goods {
    constructor(itemInfo,columns,shopInfo) {
        this.title = itemInfo.title
        this.desc = itemInfo.desc
        this.newPrice = itemInfo.price
        this.oldPrice = itemInfo.oldPrice
        this.discount = itemInfo.discountDesc
        this.columns = columns
        this.services = shopInfo.services
        this.realPrice = itemInfo.lowNowPrice
    }
}

// 商家信息封装对象
export class Shop{
    constructor(shopInfo) {
        this.logo = shopInfo.shopLogo;
        this.name = shopInfo.name;
        this.fans = shopInfo.cFans;
        this.sells = shopInfo.cSells;
        this.score = shopInfo.score;
        this.goodsCount = shopInfo.cGoods
    }
}

// 封装详情页的商品具体参数信息
export class GoodsParam {
    constructor(info, rule) {
      // 注: images可能没有值(某些商品有值, 某些没有值)
      this.image = info.images ? info.images[0] : '';
      this.infos = info.set;
      this.sizes = rule.tables;
    }
}
  
// 详情页推荐数据

export function getRecommend() {
    return request({
      url: '/recommend'
    })
  }